<?php

 class __driver_forms {
 	private $forms = array();
 	
 	public function create($formName, $formArray, $type="simple", $dbInfo = array()) {
 		if(isset($this->forms[$formName])) trigger_error("drv(FORMS): Form name '{$formName}' exists");
 		
 		if($type == "byDB_change") {
 			
 			$select = $array = array();
 			foreach($formArray as $fArr) {
 				$select[] = $fArr['column'];
 			}
 			
 			$query = "SELECT ".implode(', ', $select)." FROM {$dbInfo['table']} WHERE {$dbInfo['WHERE'][0]} LIMIT 1";
 			$array[] = $dbInfo['WHERE'][1];
 			
 			$res = drv(DB)->query($query, $array);
 			$row = &$res->fetchRow(DB_FETCHMODE_ASSOC);
 			
 			drv(DISP)->assign('formRow', &$row);
 		}
 		
 		drv(DISP)->assign(array(
 			'formName'  => $formName,
 			'formArray' => $formArray
 		));
 		
 		$this->forms[$formName] = drv(DISP)->fetch('forms_default.html');
 	}
 	
 	/**
 	 * Вернет HTML формы по её имени
 	 * 
 	 * @param string $formName имя формы
 	 * @return HTML
 	 */
 	public function getHTML($formName) {
 		return $this->forms[$formName];
 	} 
 	
 	
    // Hold an instance of the class
    private static $instance;
    
    // A private constructor; prevents direct creation of object
    private function __construct() 
    {
        
        
    }
    
    // The singleton method
    public static function si() 
    {
        if (!isset(self::$instance)) {
            $c = __CLASS__;
            self::$instance = new $c;
        }

        return self::$instance;
    }

    // Prevent users to clone the instance
    public function __clone()
    {
        trigger_error('Clone is not allowed.', E_USER_ERROR);
    }
 
 }

?>